﻿using Microsoft.WindowsAzure.Storage.Blob;
using SpaceNeedle.City6473.Web.Data.Repositories;
using SpaceNeedle.City6473.WebSite.Controllers;
using SpaceNeedle.SDK.Cloud.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SpaceNeedle.City6473.WebSite
{
    public class AzureStorageConfig
    {
        public static void Initialize()
        {
            //Instantiate Azure Storage
            AzureStorage.Init("storageAccount");

            var blobClient = AzureStorage.Account.CreateCloudBlobClient();

            // Retrieve a reference to a container. 
            CloudBlobContainer container = blobClient.GetContainerReference(RequestItemRepository.ContainerName);
            container.CreateIfNotExists();

            container.SetPermissions(new BlobContainerPermissions
            {
                PublicAccess =
                BlobContainerPublicAccessType.Blob
            });

            container = blobClient.GetContainerReference(AppContentsController.ContainerName);
            container.CreateIfNotExists();

            container.SetPermissions(new BlobContainerPermissions
            {
                PublicAccess =
                BlobContainerPublicAccessType.Blob
            });

            ////Create Tables if necessary
            //AzureStorage.SetupTable(AppRepository.TableName);
            //AzureStorage.SetupTable(UserRepository.TableName);
            //AzureStorage.SetupTable(TokenRepository.TableName);
        }
    }
}